<template>
  <div class="app-container home">

    <el-row :gutter="10" class="mb8">
	    <my-right-toolbar @queryTable="getList"></my-right-toolbar>
    </el-row>

    <el-tabs type="border-card" v-loading="loading">
      <el-tab-pane label="磅盈设置">
        <el-form ref="elForm" :model="formData" :rules="rules" size="medium" label-width="100px">
          <el-form-item label-width="130px" label="酸洗入口磅盈" prop="sxinput">
            <el-input-number size="mini" v-model="formData.sxinput" placeholder="酸洗入口磅盈" :precision='3'>
            </el-input-number>
            <el-tag style="margin-left:10px;">‰</el-tag>
          </el-form-item>
          <el-form-item label-width="130px" label="酸洗出口磅盈" prop="sxout">
            <el-input-number size="mini" v-model="formData.sxout" placeholder="酸洗出口磅盈" :precision='3'></el-input-number>
            <el-tag style="margin-left:10px;">‰</el-tag>
          </el-form-item>
          <el-form-item label-width="130px" label="轧硬入口磅盈" prop="zyinput">
            <el-input-number size="mini" v-model="formData.zyinput" placeholder="轧硬入口磅盈" :precision='3'></el-input-number>
            <el-tag style="margin-left:10px;">‰</el-tag>
          </el-form-item>
          <el-form-item label-width="130px" label="轧硬出口磅盈" prop="zyout">
            <el-input-number size="mini" v-model="formData.zyout" placeholder="轧硬出口磅盈" :precision='3'></el-input-number>
            <el-tag style="margin-left:10px;">‰</el-tag>
          </el-form-item>
          <el-form-item label-width="130px" label="镀锌入口磅盈" prop="dxinput">
            <el-input-number size="mini" v-model="formData.dxinput" placeholder="镀锌入口磅盈" :precision='3'></el-input-number>
            <el-tag style="margin-left:10px;">‰</el-tag>
          </el-form-item>
          <el-form-item label-width="130px" label="镀锌出口磅盈" prop="dxout">
            <el-input-number size="mini" v-model="formData.dxout" placeholder="镀锌出口磅盈" :precision='3'></el-input-number>
            <el-tag style="margin-left:10px;">‰</el-tag>
          </el-form-item>
          <el-form-item label-width="130px" label="彩涂入口磅盈" prop="ctinput">
            <el-input-number size="mini" v-model="formData.ctinput" placeholder="彩涂入口磅盈" :precision='3'></el-input-number>
            <el-tag style="margin-left:10px;">‰</el-tag>
          </el-form-item>
          <el-form-item label-width="130px" label="彩涂出口磅盈" prop="ctout">
            <el-input-number size="mini" v-model="formData.ctout" placeholder="彩涂出口磅盈" :precision='3'></el-input-number>
            <el-tag style="margin-left:10px;">‰</el-tag>
          </el-form-item>
          <el-form-item size="large" style="">
            <el-button type="primary" size="mini" @click="submitForm">提交</el-button>
          </el-form-item>
        </el-form>
      </el-tab-pane>
      <el-tab-pane label="AAAA">AAAA</el-tab-pane>
      <el-tab-pane label="BBBB">BBBB</el-tab-pane>
      <el-tab-pane label="CCCC">CCCC</el-tab-pane>
    </el-tabs>
  </div>
</template>
<script>
import { addBangYing, listBangYing } from "@/api/erp/system/other";

export default {
  components: {},
  props: [],
  data() {
    return {
      // 遮罩层
      loading: true,
      //erpOther:{},
      formData: {
        sxinput: 0,
        sxout: 0,
        zyinput: 0,
        zyout: 0,
        dxinput: 0,
        dxout: 0,
        ctinput: 0,
        ctout: 0,
      },
      rules: {
        sxinput: [{
          required: true,
          message: '酸洗入口磅盈',
          trigger: 'blur'
        }],
        sxout: [{
          required: true,
          message: '酸洗出口磅盈',
          trigger: 'blur'
        }],
        zyinput: [{
          required: true,
          message: '轧硬入口磅盈',
          trigger: 'blur'
        }],
        zyout: [{
          required: true,
          message: '轧硬出口磅盈',
          trigger: 'blur'
        }],
        dxinput: [{
          required: true,
          message: '镀锌入口磅盈',
          trigger: 'blur'
        }],
        dxout: [{
          required: true,
          message: '镀锌出口磅盈',
          trigger: 'blur'
        }],
        ctinput: [{
          required: true,
          message: '彩涂入口磅盈',
          trigger: 'blur'
        }],
        ctout: [{
          required: true,
          message: '彩涂出口磅盈',
          trigger: 'blur'
        }],
      },
    }
  },
  computed: {},
  watch: {},
  created() {
    this.getList();
  },
  mounted() {},
  methods: {
    getList(){
      this.loading = true;
      listBangYing().then((response) => {
        this.formData = response.data;
        this.loading = false;
      });
    },
    submitForm() {
      this.$refs['elForm'].validate(valid => {
        if (!valid) return
          var erpOther = {
            erpOtherList:[ 
            {  keyId : 0,
              otherValue : this.formData.sxinput,
              otherName :  '酸洗入口磅盈',
              otherType : 0, },
            { keyId : 1,
              otherValue : this.formData.sxout,
              otherName :  '酸洗出口磅盈',
              otherType : 1, },
            { keyId : 2,
              otherValue : this.formData.zyinput,
              otherName :  '轧硬入口磅盈',
              otherType : 2, },
            { keyId : 3,
              otherValue : this.formData.zyout,
              otherName :  '轧硬出口磅盈',
              otherType : 3, },
            { keyId : 4,
              otherValue : this.formData.dxinput,
              otherName :  '镀锌入口磅盈',
              otherType : 4, },
            { keyId : 5,
              otherValue : this.formData.dxout,
              otherName :  '镀锌出口磅盈',
              otherType : 5, },
            { keyId : 6,
              otherValue : this.formData.ctinput,
              otherName :  '彩涂入口磅盈',
              otherType : 6, },
            { keyId : 7,
              otherValue : this.formData.ctout,
              otherName :  '彩涂出口磅盈',
              otherType : 7,  }]
          }
        
        addBangYing(erpOther).then(response => {
          this.msgSuccess("修改成功");
          this.resetForm();
          this.getList();
        });
      })
    },
    resetForm() {
      this.$refs['elForm'].resetFields()
    },
  }
}
</script>

<style>

</style>
